import cv2 as cv
import numpy as np
def time_test():
    img1 = cv.imread('../LingXiao.png')
    e1 = cv.getTickCount()  # 返回从参考事件（如打开系统）到调用此函数之间的时钟周期数
    for i in range(5,49,2):
        img1 = cv.medianBlur(img1,i)    #中值滤波
    e2 = cv.getTickCount()
    t = (e2 - e1)/cv.getTickFrequency() # 计算运行时间
    print( t )

# OpenCV 中的默认优化是否打开
print(cv.useOptimized())
time_test()

# 对比禁用优化
cv.setUseOptimized(False)

# OpenCV 中的默认优化是否打开
print(cv.useOptimized())
time_test()

# True
# 0.54767947
# False
# 0.559974717